from MemModule import MemModule
from xen_helper import *

metric_list = [
    'mem_total',
    #'cached',
    #'mem_free',
    #'mem_used',
    #'buffers',
    #'swap_total',
    #'swap_cached',
    #'swap_free',
    'mem_available'
]

class XenMemModule(MemModule):

    def get_mem_total(self):
        if not self.get_val('meminfo').has_key('PhyMemTotal'):
            mem_total = xentop2list()['memtotal'][:-1]
            self.set_val(('meminfo', 'PhyMemTotal'), mem_total)

        return int(self.get_val(('meminfo', 'PhyMemTotal')))

    def get_mem_available(self):
        return self.get_mem_total() - self.get_mem_used() - \
            get_total_domU_memory()
